// Currently setup to test Undergrad objects

public class TestGraded {

	public static void main(String[] args) {
		getGPABasic();
		getGPAComplex();
		getGPAVeryComplex();
		getLastGradeBasic();
		getLastGradeComplex();
		getLastGradeVeryComplex();
		getTotalCreditsBasic();
		getTotalCreditsComplex();
		getTotalCreditsVeryComplex();
		System.out.println("All Tests Complete.");
	}
	
	public static Graded setupBasic (Graded g) {
		g.assignGrade((short)1, LetterGrade.AMINUS);
		return g;
	}
	
	public static Graded setupComplex (Graded g) {
		g.assignGrade((short)1, LetterGrade.EPURE);
		g.assignGrade((short)2, LetterGrade.DPURE);
		g.assignGrade((short)3, LetterGrade.CPURE);
		g.assignGrade((short)4, LetterGrade.BPURE);
		g.assignGrade((short)5, LetterGrade.APURE);
		return g;
	}
	
	public static Graded setupVeryComplex (Graded g) {
		g.assignGrade((short)1, LetterGrade.EPURE);
		g.assignGrade((short)2, LetterGrade.DPURE);
		g.assignGrade((short)2, LetterGrade.DPLUS);
		g.assignGrade((short)3, LetterGrade.CPURE);
		g.assignGrade((short)3, LetterGrade.CMINUS);
		g.assignGrade((short)3, LetterGrade.CPLUS);
		g.assignGrade((short)4, LetterGrade.BPURE);
		g.assignGrade((short)4, LetterGrade.BMINUS);
		g.assignGrade((short)4, LetterGrade.BPLUS);
		g.assignGrade((short)5, LetterGrade.APURE);
		g.assignGrade((short)5, LetterGrade.AMINUS);
		return g;
	}
	
	public static void getGPABasic () {
		float expected = (float)(5*3.7)/(5);
		Graded g = new Undergrad();
		g = setupBasic(g);
		if(Float.compare(g.getGPA(), expected) != 0) {
			System.out.println("getGPABasic failed - expected 3.7, got " + g.getGPA());
		}
	}

	
	public static void getGPAComplex() {
		float expected = (float)(5*4+4*3+3*2+2*1+1*0)/(5+4+3+2+1);
		Graded g = new Undergrad();
		g = setupComplex(g);
		if(Float.compare(g.getGPA(), expected) != 0) {
			System.out.println("getGPAComplex failed - expected " + expected + ", got " + g.getGPA());
		}
	}
	public static void getGPAVeryComplex() {
		float expected = (float)(5*(4+3.7)+4*(3.3+3+2.7)+3*(2.3+2+1.7)+2*(1+1.3))/(2*5+3*4+3*3+2*2+1);
		Graded g = new Undergrad();
		g = setupVeryComplex(g);
		if(Float.compare(g.getGPA(), expected) != 0) {
			System.out.println("getGPAComplex failed - expected " + expected + ", got " + g.getGPA());
		}
	}
	
	
	public static void getLastGradeBasic() {
		Graded g = new Undergrad();
		g = setupBasic(g);
		if (g.getLastGrade() != LetterGrade.AMINUS) {
			System.out.println("getLastGradeBasic failed - expected " + LetterGrade.AMINUS + ", got " + g.getLastGrade());
		}
	}
	
	public static void getLastGradeComplex() {
		Graded g = new Undergrad();
		g = setupComplex(g);
		if (g.getLastGrade() != LetterGrade.APURE) {
			System.out.println("getLastGradeComplex failed - expected " + LetterGrade.APURE + ", got " + g.getLastGrade());
		}
	}
	
	public static void getLastGradeVeryComplex() {
		Graded g = new Undergrad();
		g = setupVeryComplex(g);
		if (g.getLastGrade() != LetterGrade.AMINUS) {
			System.out.println("getLastGradeVeryComplex failed - expected " + LetterGrade.AMINUS + ", got " + g.getLastGrade());
		}
	}
	
	public static void getTotalCreditsBasic() {
		int expected = 1;
		Graded g = new Undergrad();
		g = setupBasic(g);
		if (g.getTotalCredits() != expected) {
			System.out.println("getTotalCreditsBasic failed - expected " + expected + ", got " + g.getTotalCredits());
		}
	}
	public static void getTotalCreditsComplex() {
		int expected = 5+4+3+2+1;
		Graded g = new Undergrad();
		g = setupComplex(g);
		if (g.getTotalCredits() != expected) {
			System.out.println("getTotalCreditsComplex failed - expected " + expected + ", got " + g.getTotalCredits());
		}
	}
	public static void getTotalCreditsVeryComplex() {
		int expected = (2*5+3*4+3*3+2*2+1);
		Graded g = new Undergrad();
		g = setupVeryComplex(g);
		if (g.getTotalCredits() != expected) {
			System.out.println("getTotalCreditsVeryComplex failed - expected " + expected + ", got " + g.getTotalCredits());
		}
	}
}
